<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f = "http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"  
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Edit-RefPortal</title>
    </h:head> 
    <h:body> 
        <ui:composition template="./BannersAndMenusTemplate.jsf">

            <ui:define name="content">
                <h:form id="form" rendered="#{user.getlogin()}"> 
                    
                    <p:panel header="Editing an Account">  
                        <p style="color:blue">* Please note, sections with a red asterisk are required * </p>
                        <h:panelGrid columns="3">    
                            Name: <h:outputLabel  style="color:red" value="*" />    
                            <p:inputText value = "#{user.name}"/>     
                            <!--<p:watermark for="email" value="Email Address *" />
                            <p:message for="email" /> -->  

                            Email: <h:outputLabel  style="color:red" value="*" />  


                            <p:inputText  id="email" required="true" label="email" size="40"
                                         requiredMessage="Please enter your email address."
                                         validatorMessage="Incorrect email format"      
                                         value="#{user.email}" >

                                <f:validateRegex
                                    pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />

                            </p:inputText> 
                            
                            Current Password: <h:outputLabel  style="color:red" value="*" /> 
                            <p:password  id="pwd10" value="#{user.currentpassword}"  required="true"/>   
                            
                        </h:panelGrid>   

                        <p style="color:blue">* Please leave empty if you do not wish to change your password *</p>
                        <h:panelGrid columns="2" id="matchGrid"> 

                            <h:outputLabel for="pwd1" value="Password:" />  
                            <p:password id="pwd1" value="#{user.password}" match="pwd2" label="Password 1" required="false"/>  
                            <h:outputLabel for="pwd2" value="Confirm Password:" />  
                            <p:password id="pwd2" value="#{user.password}" label="Password 2" required="false"/>  
                        </h:panelGrid>  

                      
                        <p:commandButton id="saveButton" update="matchGrid" value="Change" action = "#{user.changeUser}"/>  

                    </p:panel>      
                </h:form>
                <h:form rendered="#{user.login2}"> 
                    <a href="login.jsf">please log in again</a> 
                </h:form>
            </ui:define>

        </ui:composition>


    </h:body>

</html>

